	var appId;
	var timeStamp;
	var nonceStr;
	var packageId;
	var signType;
	var paySign;
	var orderNo;
/*打赏*/
function wxprepaydodashng(prid,mid) {
 
			var jljf=$("#jljf").text();
    	var rzts=$("#rzts").val();
      	var rzsj=$("#rzsj").val();
      	var istqsr=$("#isfb").val();
     	var total=$("#reduceprice").val();
     	
     	
			var requetUrl = _path + "/cRateOrder/wxprepaydo?mid="+mid+"&productxid="+prid+"&jljf="+jljf+"&istqsr="+istqsr+"&total="+total+"";
			/*alert("请求地址=" + requetUrl);*/
			if(getD(total)){
			
			//	if(getiszf(total)){  //判断是否买过新手单
				
			$.ajax({
				url : requetUrl,
				type : "POST",
				dataType : "json",
				async : false,
				error : function(request) {
					alert("连接错误！");
				},
				success : function(data) {
							//	alert("返回:" + data.result);
				
					if (data.result == "ok") {
						appId = data.appId;
						timeStamp = data.timeStamp;
						nonceStr = data.nonceStr;
						packageId = "prepay_id=" + data.prepay_id;
						signType = data.signType;
						paySign = data.paySign;
						orderNo = data.orderNo;
						// 					alert("返回appId：" + appId + ",timeStamp:" + timeStamp
						// 							+ ",nonceStr:" + nonceStr + ",packageId:"
						// 							+ packageId + ",signType:" + signType + ",paySign:"
						// 							+ paySign + ",orderNo:" + orderNo);
						//支付
						if (typeof WeixinJSBridge == "undefined") {
							if (document.addEventListener) {
								document.addEventListener('WeixinJSBridgeReady',
										jsApiCallds, false);
							} else if (document.attachEvent) {
								document.attachEvent('WeixinJSBridgeReady',
										jsApiCallds);
								document.attachEvent('onWeixinJSBridgeReady',
										jsApiCallds);
							}
						} else {
							jsApiCallds();
						}
						
					} else {
						alert("统一下单错误!");
					}
				}
			});
			//	}
			}
	 
}

function getiszf(getiszf){
	if(getiszf<200){
		$.ajax({
	         url: _path + "/cRateOrder/checkUnickorder",
	         type: "get",
	         async: false,
	         dataType: 'json',
	         success: function (data) {
	      	   if(data.statusCode==200){
						return true;
	      	   }else{
						layer.open({ content:'你已经享受过新手单,不能在买了。',skin: 'msg' ,time: 2 });//2秒后自动关闭
						return false;
	      	   }
	         }
	   });
	}
	 
	
}
/*打赏后支付状态*/	
function jsApiCallds() {
			$('.theme-popover-mask').fadeOut(100);
			$('.theme-popover').slideUp(200);
	WeixinJSBridge.invoke('getBrandWCPayRequest', {
		"appId" : appId, //公众号名称
		"timeStamp" : timeStamp, //时间戳，自1970年以来的秒数     
		"nonceStr" : nonceStr, //随机串     
		"package" : packageId,
		"signType" : signType, //微信签名方式
		"paySign" : paySign
	}, function(res) {
		WeixinJSBridge.log(res.err_msg);
		if (res.err_msg == "get_brand_wcpay_request:ok") {
			layer.open({ content: "支付成功!",skin: 'msg' ,time: 2 });//2秒后自动关闭

		  location.href=_path+"/member";
				
		//	saveVisitLog(${watchUser.liveId}, '${watchUser.openid }','${watchUser.nickname }','${watchUser.headimgurl }','${watchUser.sex}', "打赏", "1");
		} else {
			//删除红包信息
			alert("未支付成功！");
			deleteRedPacket(orderNo);
		 
			
		}
	});
}

function getD(total){
	  if(!isNaN(total)){
		  return true;
 }else{
	   alert("请输入正确的金额!");
//	  / $("#sjTotal").focus();
	   return false;
 }
}

	

